package io.github.harmonly.mapper;

import io.github.harmonly.entity.activity.Participant;
import io.github.harmonly.entity.association.Member;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ParticipantMapper {

    @Select("select * from member")
    List<Participant> getParticipants();

    @Select("select * from participant where cid = #{cid}")
    List<Participant> getParticipantByActivity(int cid);

    @Select("select * from participant where uid = #{uid}")
    List<Participant> getParticipantByUser(int uid);

    @Select("select * from participant where uid = #{uid} and cid = #{cid}")
    Participant isJoin(Participant participant);

    @Insert("insert into participant(uid, cid) VALUES (#{uid}, #{cid})")
    int addParticipant(Participant participant);

    @Delete("delete participant from participant where uid = #{uid} and cid = #{cid}")
    int deleteParticipant(Participant participant);
}
